package rss.services 
{
	import flash.events.IEventDispatcher;
	import rss.builder.XmlRssFeedBuilder;
	import rss.events.RssFeedEvent;
	import rss.IRssFeedBuilder;
	import rss.IRssFeedModel;
	import rss.IRssService;
	/**
	 * Simple static service for testing RSS parser and view.
	 * 
	 * @author Luke Van In
	 */
	public class RssDummyService implements IRssService  
	{
		
		//
		private var _eventDispatcher:IEventDispatcher;
		
		
		
		/**
		 * 
		 * @param	eventDispatcher
		 */
		public function RssDummyService(eventDispatcher:IEventDispatcher) 
		{
			this._eventDispatcher = eventDispatcher;
		}
		
		
		
		

		/* INTERFACE rss.IRssService */
		
		/**
		 * 
		 * @param	url
		 */
		public function loadFeed(url:String):void 
		{
			trace("RssDummyService > loadFeed");
			
			
			// get XML data from loader
			var xml:XML = <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
						  <channel> 
							<title>Mail &amp; Guardian News Feed</title> 
								
								   <link>http://www.mg.co.za/section/</link> 
								
							<description>RSS feed for all of the Mail &amp; Guardian Online news stories</description> 
							<language>en-gb</language> 
							<pubDate>Tue, 08 Mar 2011 21:15:04 +0200</pubDate> 
							<lastBuildDate>Tue, 08 Mar 2011 21:15:04 +0200</lastBuildDate> 
							<generator>M&amp;G Web Server</generator> 
							<managingEditor>editor@mg.co.za (Keith Nicholls)</managingEditor> 
							<webMaster>editor@mg.co.za (Keith Nicholls)</webMaster> 
							<ttl>15</ttl> 
							<atom:link href="http://www./rss" rel="self" type="application/rss+xml" /> 
												<item> 
										<title><![CDATA[Probe into estate board boss Mapetla's sacking]]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-probe-into-estate-board-boss-mapetlas-sacking/</link> 
										<description><![CDATA[The department of trade and industry has appointed an independent firm to compile a report on the dismissal of chief executive officer the EAAB.]]></description> 
										<pubDate>Tue, 08 Mar 2011 20:28:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-probe-into-estate-board-boss-mapetlas-sacking/</guid> 
														<category>National</category> 
									</item> 
								
												<item> 
										<title><![CDATA[From sports cars to slums: China's huge wealth gap]]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-from-sports-cars-to-slums-chinas-huge-wealth-gap/</link> 
										<description><![CDATA[Li Fu is 29, owns five cars and has a diamond-encrusted cell phone. Wang Qingzhan is 44, works as a cleaner and lives with his family in a tiny room.]]></description> 
										<pubDate>Tue, 08 Mar 2011 20:12:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-from-sports-cars-to-slums-chinas-huge-wealth-gap/</guid> 
														<category>International</category> 
									</item> 
								
												<item> 
										<title><![CDATA[Côte d'Ivoire's Gbagbo snubs African Union mediation ]]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-cte-divoires-gbagbo-snubs-african-union-mediation/</link> 
										<description><![CDATA[Côte d'Ivoire strongman Laurent Gbagbo will skip African Union-hosted talks with his rival for the presidency, his party said on Tuesday.]]></description> 
										<pubDate>Tue, 08 Mar 2011 20:01:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-cte-divoires-gbagbo-snubs-african-union-mediation/</guid> 
														<category>Africa</category> 
									</item> 
								
												<item> 
										<title><![CDATA[Stand-in skipper Taylor savours New Zealand win]]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-standin-skipper-taylor-savours-new-zealand-win/</link> 
										<description><![CDATA[Stand-in skipper Ross Taylor on Tuesday said New Zealand would savour their first win of the 2011 World Cup over Pakistan.]]></description> 
										<pubDate>Tue, 08 Mar 2011 19:46:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-standin-skipper-taylor-savours-new-zealand-win/</guid> 
														<category>Sport</category> 
									</item> 
								
												<item> 
										<title><![CDATA[DA: The ANC has abandoned non-racialism]]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-da-the-anc-has-abandoned-nonracialism/</link> 
										<description><![CDATA[The ANC's defence of government spokesperson Jimmy Manyi is proof the ruling party has abandoned non-racialism, DA MP Wilmot James said on Tuesday.]]></description> 
										<pubDate>Tue, 08 Mar 2011 18:55:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-da-the-anc-has-abandoned-nonracialism/</guid> 
														<category>National</category> 
									</item> 
								
												<item> 
										<title><![CDATA[Libya no-fly zone calls mount as new battles loom ]]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-libya-nofly-zone-calls-mount-as-new-battles-loom/</link> 
										<description><![CDATA[Libya's air force stepped up air strikes and heavy shelling was heard on Tuesday as the revolt against Muammar Gaddafi entered its third week.]]></description> 
										<pubDate>Tue, 08 Mar 2011 18:43:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-libya-nofly-zone-calls-mount-as-new-battles-loom/</guid> 
														<category>Africa</category> 
									</item> 
								
												<item> 
										<title><![CDATA[Labour law debate 'based on disinformation']]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-labour-law-debate-based-on-disinformation/</link> 
										<description><![CDATA[The controversial Employment Equity Amendment Bill is meant to fight white male domination in management positions, the ANC said on Tuesday.]]></description> 
										<pubDate>Tue, 08 Mar 2011 17:29:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-labour-law-debate-based-on-disinformation/</guid> 
														<category>Business</category> 
									</item> 
								
												<item> 
										<title><![CDATA[Sasol buys R7bn stake in Canada gas field]]></title> 
										<link>http://www.mg.co.za/article/2011-03-08-sasol-buys-r7bn-stake-in-canada-gas-field/</link> 
										<description><![CDATA[Petrochemical company Sasol will buy a 50% stake in a shale gas field in Canada for R7,14-billion, it said on Tuesday.]]></description> 
										<pubDate>Tue, 08 Mar 2011 17:29:00 +0200</pubDate> 
										<guid>http://www.mg.co.za/article/2011-03-08-sasol-buys-r7bn-stake-in-canada-gas-field/</guid> 
														<category>Business</category> 
									</item> 
								
							  </channel> 
						</rss> 
			
		
			// build the feed from the XML
			var feedBuilder:IRssFeedBuilder = new XmlRssFeedBuilder(xml);

			var feed:IRssFeedModel = feedBuilder.buildFeed();
			

			// dispose resources
			feedBuilder.dispose();
			
			
			// create and dispatch the event
			var event:RssFeedEvent = new RssFeedEvent(RssFeedEvent.LOADED, feed);
			
			this._eventDispatcher.dispatchEvent(event);
		}
		
		
		/**
		 * 
		 */
		public function dispose():void 
		{
			
		}
		
	}

}